[3.9] gh-108342: Make ssl TestPreHandshakeClose more reliable (GH-108370) (#108407)
authorŁukasz Langa <lukasz@langa.pl>
Thu, 24 Aug 2023 10:09:11 +0000 (12:09 +0200)
committerAndrej Shadura <andrewsh@debian.org>
Tue, 20 Jan 2026 10:45:10 +0000 (11:45 +0100)
commit2656ba34a6b4c976aa4b7e09c6df04dd1ecb6819
tree8a1378abc8d911e039a51de036890d065bdcd20f
parent1989a562de692dd88e252ede32c715c53e82016f
[3.9] gh-108342: Make ssl TestPreHandshakeClose more reliable (GH-108370) (#108407)

* In preauth tests of test_ssl, explicitly break reference cycles
  invoving SingleConnectionTestServerThread to make sure that the
  thread is deleted. Otherwise, the test marks the environment as
  altered because the threading module sees a "dangling thread"
  (SingleConnectionTestServerThread). This test leak was introduced
  by the test added for the fix of issue gh-108310.
* Use support.SHORT_TIMEOUT instead of hardcoded 1.0 or 2.0 seconds
  timeout.
* SingleConnectionTestServerThread.run() catchs TimeoutError
* Fix a race condition (missing synchronization) in
  test_preauth_data_to_tls_client(): the server now waits until the
  client connect() completed in call_after_accept().
* test_https_client_non_tls_response_ignored() calls server.join()
  explicitly.
* Replace "localhost" with server.listener.getsockname()[0].
(cherry picked from commit 592bacb6fc0833336c0453e818e9b95016e9fd47)

Co-authored-by: Victor Stinner <vstinner@python.org>
Gbp-Pq: Name 0018-3.9-gh-108342-Make-ssl-TestPreHandshakeClose-more-re.patch
Lib/test/test_ssl.py